package lottery.office;

import java.util.Arrays;

public class LotteryOffice {
	private int couponId;
	private int[] tableOfCheckedNumbers;

	private int checkHits(int[] tableOfCheckedNumbers, int[] tableOfDrawedBalls) {
		int numberOfHits = 0;
		// Arrays.sort(tableOfCheckedNumbers);
		Arrays.sort(tableOfDrawedBalls);
		for (int i = 0; i < tableOfCheckedNumbers.length; i++) {
			int result = Arrays.binarySearch(tableOfDrawedBalls, tableOfCheckedNumbers[i]);
			if (result >= 0) {
				numberOfHits++;
			}
			// System.out.println(result);
		}

		return numberOfHits;
	}

	public int getCouponId() {
		return couponId;
	}

	public void setCouponId(int couponId) {
		this.couponId = couponId;
	}

	public int[] getTableOfCheckedNumbers() {
		return tableOfCheckedNumbers;
	}

	public void setTableOfCheckedNumbers(int[] tableOfCheckedNumbers) {
		this.tableOfCheckedNumbers = tableOfCheckedNumbers;
	}

	public static void main(String[] args) {
		int[] tableOfCheckedNumbers = { 1, 2, 7, 9, 5, 6 };
		int[] tableOfDrawedBalls = { 1, 2, 7, 3, 66, 6 };
		LotteryOffice lottery = new LotteryOffice();
		System.out.println(lottery.checkHits(tableOfCheckedNumbers,
				tableOfDrawedBalls));
	}
}